package com.six666.medicaldevicetestingsystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.six666.medicaldevicetestingsystem.entity.MessageList;
import com.six666.medicaldevicetestingsystem.mapper.MessageList_Mapper;
import com.six666.medicaldevicetestingsystem.service.MessageList_Service;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageList_Service_Impl extends ServiceImpl<MessageList_Mapper, MessageList> implements MessageList_Service{
    @Override
    public List<MessageList> get_message_list_by_type(String type) {
        QueryWrapper<MessageList> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("MessageType", type);
        return list(queryWrapper);
    }
    @Override
    public boolean create_message(MessageList messageList){
        return save(messageList);
    }

    @Override
    public boolean finish(Integer  message_id){
        UpdateWrapper<MessageList> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("MessageID", message_id).set("State", "Finish");
        return update(updateWrapper);
    }

    @Override
    public List<MessageList> get_all_message() {
        return list();
    }
}
